{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Initialization"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = np.zeros((3,3,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[[0., 0., 0.],\n",
       "        [0., 0., 0.],\n",
       "        [0., 0., 0.]],\n",
       "\n",
       "       [[0., 0., 0.],\n",
       "        [0., 0., 0.],\n",
       "        [0., 0., 0.]],\n",
       "\n",
       "       [[0., 0., 0.],\n",
       "        [0., 0., 0.],\n",
       "        [0., 0., 0.]]])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[[1, 1, 1, 1],\n",
       "        [1, 1, 1, 1]],\n",
       "\n",
       "       [[1, 1, 1, 1],\n",
       "        [1, 1, 1, 1]]])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.ones((2,2,4), dtype=int)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([['hellott', 'hellott'],\n",
       "       ['hellott', 'hellott']], dtype='<U7')"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.full((2,2),\"hellottwyyw\", dtype='<U7')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.12520064, 0.07562049, 0.12900815, 0.55747886, 0.11532656,\n",
       "       0.53774122, 0.06926235, 0.29796341, 0.09515193, 0.05531125])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.random.rand(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = np.random.randint(5,10,(10,10))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Access of NumPy "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[6, 6, 7, 7, 5, 6, 9, 9, 8, 7],\n",
       "       [8, 5, 9, 5, 7, 8, 5, 9, 6, 8],\n",
       "       [7, 7, 6, 6, 5, 9, 6, 6, 5, 9],\n",
       "       [5, 6, 9, 6, 8, 9, 9, 6, 9, 8]])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[4:8]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[5, 6],\n",
       "       [7, 8],\n",
       "       [5, 9],\n",
       "       [8, 9]])"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[4:8,4:6]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[5, 6],\n",
       "       [7, 8]])"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[4:6,4:6]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Combine Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "data1 = np.random.randint(5,15,size=(5,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "data2 = np.random.randint(5,15,size=(5,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 8, 10, 14,  6, 13,  6],\n",
       "       [ 6, 10, 14, 10, 14, 13],\n",
       "       [12,  5, 13,  5,  8, 13],\n",
       "       [ 5, 14, 10, 12,  9,  6],\n",
       "       [ 9,  7, 14, 13,  9,  8]])"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.hstack([data1,data2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 8, 10, 14],\n",
       "       [ 6, 10, 14],\n",
       "       [12,  5, 13],\n",
       "       [ 5, 14, 10],\n",
       "       [ 9,  7, 14],\n",
       "       [ 6, 13,  6],\n",
       "       [10, 14, 13],\n",
       "       [ 5,  8, 13],\n",
       "       [12,  9,  6],\n",
       "       [13,  9,  8]])"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.vstack([data1, data2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 8, 10, 14,  6, 13,  6],\n",
       "       [ 6, 10, 14, 10, 14, 13],\n",
       "       [12,  5, 13,  5,  8, 13],\n",
       "       [ 5, 14, 10, 12,  9,  6],\n",
       "       [ 9,  7, 14, 13,  9,  8]])"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.concatenate([data1, data2], axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [],
   "source": [
    "data1 = np.random.randint(5,15,size=(5,3,2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [],
   "source": [
    "data2 = np.random.randint(5,15,size=(5,3,2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[[ 5, 14, 14, 14],\n",
       "        [ 8,  9, 10,  8],\n",
       "        [12,  9, 14,  5]],\n",
       "\n",
       "       [[ 6, 11,  6, 12],\n",
       "        [ 9,  6,  5, 10],\n",
       "        [10,  6,  9,  8]],\n",
       "\n",
       "       [[11, 13,  8,  5],\n",
       "        [13, 14, 12,  6],\n",
       "        [ 7,  9, 14,  6]],\n",
       "\n",
       "       [[13,  9,  5, 11],\n",
       "        [ 5, 10,  5,  7],\n",
       "        [ 6,  5, 14,  6]],\n",
       "\n",
       "       [[ 5, 14, 11,  8],\n",
       "        [ 5,  5,  6,  9],\n",
       "        [ 7, 11, 11, 11]]])"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.concatenate([data1, data2], axis=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Splitting Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [],
   "source": [
    "a1,a2 = np.hsplit(data,[5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[9, 6, 5, 7, 9],\n",
       "       [8, 9, 9, 6, 9],\n",
       "       [9, 9, 8, 6, 7],\n",
       "       [5, 5, 5, 6, 5],\n",
       "       [6, 6, 7, 7, 5],\n",
       "       [8, 5, 9, 5, 7],\n",
       "       [7, 7, 6, 6, 5],\n",
       "       [5, 6, 9, 6, 8],\n",
       "       [6, 9, 6, 6, 7],\n",
       "       [5, 7, 5, 5, 6]])"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "b1,b2,b3 = np.vsplit(data,[5,7])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[9, 6, 5, 7, 9, 6, 5, 5, 5, 6],\n",
       "       [8, 9, 9, 6, 9, 7, 5, 6, 7, 8],\n",
       "       [9, 9, 8, 6, 7, 7, 6, 6, 9, 5],\n",
       "       [5, 5, 5, 6, 5, 9, 9, 9, 8, 9],\n",
       "       [6, 6, 7, 7, 5, 6, 9, 9, 8, 7]])"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[8, 5, 9, 5, 7, 8, 5, 9, 6, 8],\n",
       "       [7, 7, 6, 6, 5, 9, 6, 6, 5, 9]])"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[5, 6, 9, 6, 8, 9, 9, 6, 9, 8],\n",
       "       [6, 9, 6, 6, 7, 7, 5, 8, 5, 8],\n",
       "       [5, 7, 5, 5, 6, 5, 6, 6, 5, 6]])"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Shape, Dimension"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(10, 10)"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.ndim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "100"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[9, 6, 5, 7, 9, 6, 5, 5, 5, 6, 8, 9, 9, 6, 9, 7, 5, 6, 7, 8, 9, 9,\n",
       "        8, 6, 7, 7, 6, 6, 9, 5, 5, 5, 5, 6, 5, 9, 9, 9, 8, 9, 6, 6, 7, 7,\n",
       "        5, 6, 9, 9, 8, 7],\n",
       "       [8, 5, 9, 5, 7, 8, 5, 9, 6, 8, 7, 7, 6, 6, 5, 9, 6, 6, 5, 9, 5, 6,\n",
       "        9, 6, 8, 9, 9, 6, 9, 8, 6, 9, 6, 6, 7, 7, 5, 8, 5, 8, 5, 7, 5, 5,\n",
       "        6, 5, 6, 6, 5, 6]])"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.reshape(2,50)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [],
   "source": [
    "d = np.array([1,2,3,4,5,6,7,9])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d.ndim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(8,)"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d.size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1],\n",
       "       [2],\n",
       "       [3],\n",
       "       [4],\n",
       "       [5],\n",
       "       [6],\n",
       "       [7],\n",
       "       [9]])"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d.reshape(8,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[9, 6, 5, 7, 9, 6, 5, 5, 5, 6, 8, 9, 9, 6, 9, 7, 5, 6, 7, 8],\n",
       "       [9, 9, 8, 6, 7, 7, 6, 6, 9, 5, 5, 5, 5, 6, 5, 9, 9, 9, 8, 9],\n",
       "       [6, 6, 7, 7, 5, 6, 9, 9, 8, 7, 8, 5, 9, 5, 7, 8, 5, 9, 6, 8],\n",
       "       [7, 7, 6, 6, 5, 9, 6, 6, 5, 9, 5, 6, 9, 6, 8, 9, 9, 6, 9, 8],\n",
       "       [6, 9, 6, 6, 7, 7, 5, 8, 5, 8, 5, 7, 5, 5, 6, 5, 6, 6, 5, 6]])"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.reshape(-1,20)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Utility Function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "683"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.sum(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([63, 74, 72, 70, 70, 70, 66, 75, 67, 56])"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.sum(data, axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[9, 6, 5, 7, 9, 6, 5, 5, 5, 6],\n",
       "       [8, 9, 9, 6, 9, 7, 5, 6, 7, 8],\n",
       "       [9, 9, 8, 6, 7, 7, 6, 6, 9, 5],\n",
       "       [5, 5, 5, 6, 5, 9, 9, 9, 8, 9],\n",
       "       [6, 6, 7, 7, 5, 6, 9, 9, 8, 7],\n",
       "       [8, 5, 9, 5, 7, 8, 5, 9, 6, 8],\n",
       "       [7, 7, 6, 6, 5, 9, 6, 6, 5, 9],\n",
       "       [5, 6, 9, 6, 8, 9, 9, 6, 9, 8],\n",
       "       [6, 9, 6, 6, 7, 7, 5, 8, 5, 8],\n",
       "       [5, 7, 5, 5, 6, 5, 6, 6, 5, 6]])"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.41211849, -0.2794155 , -0.95892427,  0.6569866 ,  0.41211849,\n",
       "        -0.2794155 , -0.95892427, -0.95892427, -0.95892427, -0.2794155 ],\n",
       "       [ 0.98935825,  0.41211849,  0.41211849, -0.2794155 ,  0.41211849,\n",
       "         0.6569866 , -0.95892427, -0.2794155 ,  0.6569866 ,  0.98935825],\n",
       "       [ 0.41211849,  0.41211849,  0.98935825, -0.2794155 ,  0.6569866 ,\n",
       "         0.6569866 , -0.2794155 , -0.2794155 ,  0.41211849, -0.95892427],\n",
       "       [-0.95892427, -0.95892427, -0.95892427, -0.2794155 , -0.95892427,\n",
       "         0.41211849,  0.41211849,  0.41211849,  0.98935825,  0.41211849],\n",
       "       [-0.2794155 , -0.2794155 ,  0.6569866 ,  0.6569866 , -0.95892427,\n",
       "        -0.2794155 ,  0.41211849,  0.41211849,  0.98935825,  0.6569866 ],\n",
       "       [ 0.98935825, -0.95892427,  0.41211849, -0.95892427,  0.6569866 ,\n",
       "         0.98935825, -0.95892427,  0.41211849, -0.2794155 ,  0.98935825],\n",
       "       [ 0.6569866 ,  0.6569866 , -0.2794155 , -0.2794155 , -0.95892427,\n",
       "         0.41211849, -0.2794155 , -0.2794155 , -0.95892427,  0.41211849],\n",
       "       [-0.95892427, -0.2794155 ,  0.41211849, -0.2794155 ,  0.98935825,\n",
       "         0.41211849,  0.41211849, -0.2794155 ,  0.41211849,  0.98935825],\n",
       "       [-0.2794155 ,  0.41211849, -0.2794155 , -0.2794155 ,  0.6569866 ,\n",
       "         0.6569866 , -0.95892427,  0.98935825, -0.95892427,  0.98935825],\n",
       "       [-0.95892427,  0.6569866 , -0.95892427, -0.95892427, -0.2794155 ,\n",
       "        -0.95892427, -0.2794155 , -0.2794155 , -0.95892427, -0.2794155 ]])"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.sin(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[9, 8, 9, 5, 6, 8, 7, 5, 6, 5],\n",
       "       [6, 9, 9, 5, 6, 5, 7, 6, 9, 7],\n",
       "       [5, 9, 8, 5, 7, 9, 6, 9, 6, 5],\n",
       "       [7, 6, 6, 6, 7, 5, 6, 6, 6, 5],\n",
       "       [9, 9, 7, 5, 5, 7, 5, 8, 7, 6],\n",
       "       [6, 7, 7, 9, 6, 8, 9, 9, 7, 5],\n",
       "       [5, 5, 6, 9, 9, 5, 6, 9, 5, 6],\n",
       "       [5, 6, 6, 9, 9, 9, 6, 6, 8, 6],\n",
       "       [5, 7, 9, 8, 8, 6, 5, 9, 5, 5],\n",
       "       [6, 8, 5, 9, 7, 8, 9, 8, 8, 6]])"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([6.3, 7.4, 7.2, 7. , 7. , 7. , 6.6, 7.5, 6.7, 5.6])"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.mean(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1.48660687, 1.356466  , 1.4       , 1.84390889, 1.26491106,\n",
       "       1.54919334, 1.356466  , 1.5       , 1.26885775, 0.66332496])"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.std(axis=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Broadcasting"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [],
   "source": [
    "v = np.array([1,2,3,4,5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [],
   "source": [
    "s = 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([11, 12, 13, 14, 15])"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "v + s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [],
   "source": [
    "t = [10,11]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [],
   "source": [
    "#v + t"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = np.array([[1],[2],[3],[4],[5]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(5, 1)"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 2,  3,  4,  5,  6],\n",
       "       [ 3,  4,  5,  6,  7],\n",
       "       [ 4,  5,  6,  7,  8],\n",
       "       [ 5,  6,  7,  8,  9],\n",
       "       [ 6,  7,  8,  9, 10]])"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a + v"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = np.random.randint(1,5,size=(10,2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [],
   "source": [
    "b = np.random.randint(1,5,size=(5,2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[[3, 2],\n",
       "        [4, 2],\n",
       "        [3, 4],\n",
       "        [3, 3],\n",
       "        [3, 1],\n",
       "        [1, 3],\n",
       "        [2, 2],\n",
       "        [1, 1],\n",
       "        [4, 3],\n",
       "        [2, 2]]])"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.reshape(1,10,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[[-1,  2],\n",
       "        [-2,  2],\n",
       "        [-1,  0],\n",
       "        [-1,  1],\n",
       "        [-1,  3],\n",
       "        [ 1,  1],\n",
       "        [ 0,  2],\n",
       "        [ 1,  3],\n",
       "        [-2,  1],\n",
       "        [ 0,  2]],\n",
       "\n",
       "       [[-2,  2],\n",
       "        [-3,  2],\n",
       "        [-2,  0],\n",
       "        [-2,  1],\n",
       "        [-2,  3],\n",
       "        [ 0,  1],\n",
       "        [-1,  2],\n",
       "        [ 0,  3],\n",
       "        [-3,  1],\n",
       "        [-1,  2]],\n",
       "\n",
       "       [[-1,  2],\n",
       "        [-2,  2],\n",
       "        [-1,  0],\n",
       "        [-1,  1],\n",
       "        [-1,  3],\n",
       "        [ 1,  1],\n",
       "        [ 0,  2],\n",
       "        [ 1,  3],\n",
       "        [-2,  1],\n",
       "        [ 0,  2]],\n",
       "\n",
       "       [[ 1,  0],\n",
       "        [ 0,  0],\n",
       "        [ 1, -2],\n",
       "        [ 1, -1],\n",
       "        [ 1,  1],\n",
       "        [ 3, -1],\n",
       "        [ 2,  0],\n",
       "        [ 3,  1],\n",
       "        [ 0, -1],\n",
       "        [ 2,  0]],\n",
       "\n",
       "       [[ 0,  2],\n",
       "        [-1,  2],\n",
       "        [ 0,  0],\n",
       "        [ 0,  1],\n",
       "        [ 0,  3],\n",
       "        [ 2,  1],\n",
       "        [ 1,  2],\n",
       "        [ 2,  3],\n",
       "        [-1,  1],\n",
       "        [ 1,  2]]])"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b.reshape(5,1,2) - a.reshape(1,10,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = np.random.randint(1,5,size=(10,2))\n",
    "b = np.random.randint(1,5,size=(5,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(10, 2)"
      ]
     },
     "execution_count": 97,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(5, 3)"
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[[[-3, -1],\n",
       "         [ 0,  2],\n",
       "         [-1,  1]],\n",
       "\n",
       "        [[-2,  0],\n",
       "         [ 1,  3],\n",
       "         [ 0,  2]],\n",
       "\n",
       "        [[ 0, -2],\n",
       "         [ 3,  1],\n",
       "         [ 2,  0]],\n",
       "\n",
       "        [[ 0,  0],\n",
       "         [ 3,  3],\n",
       "         [ 2,  2]],\n",
       "\n",
       "        [[-1, -3],\n",
       "         [ 2,  0],\n",
       "         [ 1, -1]],\n",
       "\n",
       "        [[-2, -2],\n",
       "         [ 1,  1],\n",
       "         [ 0,  0]],\n",
       "\n",
       "        [[ 0,  0],\n",
       "         [ 3,  3],\n",
       "         [ 2,  2]],\n",
       "\n",
       "        [[-3,  0],\n",
       "         [ 0,  3],\n",
       "         [-1,  2]],\n",
       "\n",
       "        [[-1, -3],\n",
       "         [ 2,  0],\n",
       "         [ 1, -1]],\n",
       "\n",
       "        [[-2, -3],\n",
       "         [ 1,  0],\n",
       "         [ 0, -1]]],\n",
       "\n",
       "\n",
       "       [[[ 0,  2],\n",
       "         [-2,  0],\n",
       "         [ 0,  2]],\n",
       "\n",
       "        [[ 1,  3],\n",
       "         [-1,  1],\n",
       "         [ 1,  3]],\n",
       "\n",
       "        [[ 3,  1],\n",
       "         [ 1, -1],\n",
       "         [ 3,  1]],\n",
       "\n",
       "        [[ 3,  3],\n",
       "         [ 1,  1],\n",
       "         [ 3,  3]],\n",
       "\n",
       "        [[ 2,  0],\n",
       "         [ 0, -2],\n",
       "         [ 2,  0]],\n",
       "\n",
       "        [[ 1,  1],\n",
       "         [-1, -1],\n",
       "         [ 1,  1]],\n",
       "\n",
       "        [[ 3,  3],\n",
       "         [ 1,  1],\n",
       "         [ 3,  3]],\n",
       "\n",
       "        [[ 0,  3],\n",
       "         [-2,  1],\n",
       "         [ 0,  3]],\n",
       "\n",
       "        [[ 2,  0],\n",
       "         [ 0, -2],\n",
       "         [ 2,  0]],\n",
       "\n",
       "        [[ 1,  0],\n",
       "         [-1, -2],\n",
       "         [ 1,  0]]],\n",
       "\n",
       "\n",
       "       [[[-3, -1],\n",
       "         [-2,  0],\n",
       "         [-2,  0]],\n",
       "\n",
       "        [[-2,  0],\n",
       "         [-1,  1],\n",
       "         [-1,  1]],\n",
       "\n",
       "        [[ 0, -2],\n",
       "         [ 1, -1],\n",
       "         [ 1, -1]],\n",
       "\n",
       "        [[ 0,  0],\n",
       "         [ 1,  1],\n",
       "         [ 1,  1]],\n",
       "\n",
       "        [[-1, -3],\n",
       "         [ 0, -2],\n",
       "         [ 0, -2]],\n",
       "\n",
       "        [[-2, -2],\n",
       "         [-1, -1],\n",
       "         [-1, -1]],\n",
       "\n",
       "        [[ 0,  0],\n",
       "         [ 1,  1],\n",
       "         [ 1,  1]],\n",
       "\n",
       "        [[-3,  0],\n",
       "         [-2,  1],\n",
       "         [-2,  1]],\n",
       "\n",
       "        [[-1, -3],\n",
       "         [ 0, -2],\n",
       "         [ 0, -2]],\n",
       "\n",
       "        [[-2, -3],\n",
       "         [-1, -2],\n",
       "         [-1, -2]]],\n",
       "\n",
       "\n",
       "       [[[-1,  1],\n",
       "         [ 0,  2],\n",
       "         [ 0,  2]],\n",
       "\n",
       "        [[ 0,  2],\n",
       "         [ 1,  3],\n",
       "         [ 1,  3]],\n",
       "\n",
       "        [[ 2,  0],\n",
       "         [ 3,  1],\n",
       "         [ 3,  1]],\n",
       "\n",
       "        [[ 2,  2],\n",
       "         [ 3,  3],\n",
       "         [ 3,  3]],\n",
       "\n",
       "        [[ 1, -1],\n",
       "         [ 2,  0],\n",
       "         [ 2,  0]],\n",
       "\n",
       "        [[ 0,  0],\n",
       "         [ 1,  1],\n",
       "         [ 1,  1]],\n",
       "\n",
       "        [[ 2,  2],\n",
       "         [ 3,  3],\n",
       "         [ 3,  3]],\n",
       "\n",
       "        [[-1,  2],\n",
       "         [ 0,  3],\n",
       "         [ 0,  3]],\n",
       "\n",
       "        [[ 1, -1],\n",
       "         [ 2,  0],\n",
       "         [ 2,  0]],\n",
       "\n",
       "        [[ 0, -1],\n",
       "         [ 1,  0],\n",
       "         [ 1,  0]]],\n",
       "\n",
       "\n",
       "       [[[-1,  1],\n",
       "         [ 0,  2],\n",
       "         [ 0,  2]],\n",
       "\n",
       "        [[ 0,  2],\n",
       "         [ 1,  3],\n",
       "         [ 1,  3]],\n",
       "\n",
       "        [[ 2,  0],\n",
       "         [ 3,  1],\n",
       "         [ 3,  1]],\n",
       "\n",
       "        [[ 2,  2],\n",
       "         [ 3,  3],\n",
       "         [ 3,  3]],\n",
       "\n",
       "        [[ 1, -1],\n",
       "         [ 2,  0],\n",
       "         [ 2,  0]],\n",
       "\n",
       "        [[ 0,  0],\n",
       "         [ 1,  1],\n",
       "         [ 1,  1]],\n",
       "\n",
       "        [[ 2,  2],\n",
       "         [ 3,  3],\n",
       "         [ 3,  3]],\n",
       "\n",
       "        [[-1,  2],\n",
       "         [ 0,  3],\n",
       "         [ 0,  3]],\n",
       "\n",
       "        [[ 1, -1],\n",
       "         [ 2,  0],\n",
       "         [ 2,  0]],\n",
       "\n",
       "        [[ 0, -1],\n",
       "         [ 1,  0],\n",
       "         [ 1,  0]]]])"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.reshape(1,10,1,2) - b.reshape(5,1,3,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
